//南航明珠商城-电子码信息.js
function show_WdatePicker(th){
	   $(th).prev().show();
}
function setproductdate(th){
	layer.confirm("确定设置此日期？",function(){
		layer.closeAll('dialog');
		var layer_load_window = layer.load(2); 
		var str=""+$dp.cal.getP('y')+"-"+$dp.cal.getP('M')+"-"+$dp.cal.getP('d');
		var id=$("#prodId").val();
	    var url=path+"/product/set_product_down_date";
		 $.ajax({
				url : url,
				type : "post",
				dataType : "text",
				data : {
					"date":str,
					"id":id,
				},
				success : function(msg){
				 if(msg == "success"){
		   			 layer.msg('设置成功!',{icon:1,time:1000},function(){
		   				$("#query_electronic_code_batch_form").submit();
		   			 });
		   		  }else if(msg == "failone"){
		   			layer.alert("设置失败,设置的过期日期不能早于当前日期或晚于有效期");
		   		  }else if(msg="failtwo"){
		   			layer.alert("设置失败,该商品没有已确认的电子码");
		   		  }else{
		   			layer.alert("设置失败");
		   		  }
		   	  },
			  error : function(){
				  layer.alert("操作失败");
			  },complete: function(XMLHttpRequest, textStatus) {
					layer.close(layer_load_window);
			  }
			});
	});
}
function setElectronicCodeDate(th){
	layer.confirm("确定设置此日期？",function(){
		layer.closeAll('dialog');
		var layer_load_window = layer.load(2); 
	var id=$(th).attr("data-id");
	var str=""+$dp.cal.getP('y')+"-"+$dp.cal.getP('M')+"-"+$dp.cal.getP('d');
    var url=path+"/product/set_expire_date";
	 $.ajax({
			url : url,
			type : "post",
			dataType : "text",
			data : {
				"date":str,
				"id":id,
			},
			success : function(msg){
			 if(msg == "success"){
	   			 layer.msg('设置成功!',{icon:1,time:1000},function(){
		   				$("#query_electronic_code_batch_form").submit();
		   	     });
	   		  }else if(msg == "failone"){
	   			layer.alert("设置失败,设置的过期日期不能早于当前日期或晚于有效期");
	   		  }else if(msg="failtwo"){
	   			layer.alert("设置失败,已上架的商品不能设置过期日期");
	   		  }else{
	   			layer.alert("设置失败");
	   		  }
	   	  },
		  error : function(){
			  layer.alert("操作失败");
		  },complete: function(XMLHttpRequest, textStatus) {
				layer.close(layer_load_window);
		  }
	});
	});
}